import { API } from './BaseApi'
import { AppParams } from "@/utils/appParams";
import { System } from "@/api/SystemApi";

class SystemApi {
  async SelectFile () {
    const df = await API.SystemApi.SelectFile()
    return df
  }

  OpenFile (Path, FileName) {
    System.OpenFile({ Path: Path, FileName: FileName })
  }

  /**
   * 打开一个窗口文件
   * @param Uri
   * @constructor
   */
  OpenForm (Uri) {
    API.SystemApi.OpenForm(Uri)
  }

  /**
   * 打开一个dialog窗口文件
   * @param Uri
   * @constructor
   */
  OpenDialogForm (Uri) {
    API.SystemApi.OpenDialogForm(Uri)
  }

  // LoadingSystemConfig () {
  //   API.SystemApi.GetSystemConfig().then(res => {
  //     sessionStorage.setItem(AppParams.COMMON.SYSTEM_CONFIG, res)
  //   })
  // }

  static GetSystemConfigInfo () {
    const c = sessionStorage.getItem(AppParams.COMMON.SYSTEM_CONFIG)
    return JSON.parse(c)
  }

  static Ping (ip, callback) {
    API.SystemApi.Ping(ip).then(res => {
      callback && callback(res)
    })
  }
}

export default SystemApi
